<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateFrequentContactsTable extends AbstractMigration
{
    public function up()
    {
        $this->table("frequent_contacts", ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '联系人'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('chat_global_id', 'char', ['default' => '', 'limit' => 36, 'comment' => '会话id'])
            ->addColumn('user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '用户1'])
            ->addColumn('link_user_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '用户2'])
            ->addColumn('last_message_send_at', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '最后聊天时间'])
            ->create();
    }

    public function down()
    {
        $this->table("frequent_contacts")
            ->drop()
            ->save();
    }
}
